<%--
  Created by IntelliJ IDEA.
  User: nidel
  Date: 2021/5/31
  Time: 11:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>忘记密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="jsp/layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="jsp/layuimini/css/public.css" media="all">
    <link rel="stylesheet" href="jsp/layuimini/js/lay-module/step-lay/step.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item>
                            <div>
                                <div class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">员工ID:</label>
                                        <div class="layui-input-block">
                                            <input id="empno" type="number" placeholder="请填写员工ID" class="layui-input" lay-verify="number" required />

                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">员工姓名:</label>
                                        <div class="layui-input-block">
                                            <input id="ename" type="text" placeholder="请填写姓名" value="" class="layui-input"  required>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">身份证号:</label>
                                        <div class="layui-input-block">
                                            <input id="idcard" type="text" placeholder="请填写身份证号" name="identity" lay-verify="identity" placeholder="" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button id="bt-step1" class="layui-btn" lay-submit lay-filter="formStep">
                                                &emsp;下一步&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">请输入新密码:</label>
                                        <div class="layui-input-block">
                                            <input id="pass" type="text" placeholder="请填写密码" value="" class="layui-input" lay-verify="number" required>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">确认密码:</label>
                                        <div class="layui-input-block">
                                            <input id="password" type="text" placeholder="请确认密码" value="" class="layui-input" lay-verify="number" required>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button id="bt-passwordupdate" class="layui-btn" lay-submit lay-filter="formStep2">
                                                &emsp;确认修改&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        修改成功
                                    </div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn next">重新登陆 </button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
</div>
<script src="jsp/layuimini/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="jsp/layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="jsp/layuimini/js/lay-config.js?v=1.0.4" charset="utf-8"></script>

<script>
    layui.use([ 'form', 'step'], function () {
        var $ = layui.$,
            form = layui.form,
            step = layui.step;

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '500px',
            stepItems: [{
                title: '填写员工信息'
            }, {
                title: '修改密码'
            }, {
                title: '完成'
            }]
        });
        var getempno=0;
        $("#bt-step1").click(function () {
            getempno=$("#empno").val();
            $.post(
                "/login/checkempinfo",{
                    empno:getempno,
                    ename:$("#ename").val(),
                    idcard:$("#idcard").val()
                },function (data) {
                    if (data!="true"){
                        layer.msg('查无此人')
                    }else {
                        step.next('#stepForm');
                    }
                }
            )
        })

        // 修改密码
        $("#bt-passwordupdate").click(function () {
            if ($("#pass").val()!=$("#password").val()){
                layer.msg('密码不一致')
            }else{
                $.post(
                    "/login/updatepassword",{
                        updempno:getempno,
                        password:$("#password").val()},function (data){
                            step.next('#stepForm');
                    }
                )
            }
        })

            $('.pre').click(function () {
                step.pre('#stepForm');

            });

            $('.next').click(function () {
                window.location="login.jsp"
            });


    })
</script>
</body>
</html>
